﻿using CashFlow.Web.Controllers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
using System.Web.Mvc;
using Should.Fluent;
using Moq;
using DotNetOpenAuth.OpenId.RelyingParty;
using CashFlow.Repository;

namespace CashFlow.Web.Tests.Controllers
{
	[TestClass()]
	public class UserControllerTest
	{
		private UserController controller;
		private Mock<IRelyingPartyApplicationStore> relyingPartyApplicationStoreMock;
		private Mock<IAppIdentityRepository> repositoryMock;
		private Mock<ITenantRepository> tenantRepositoryMock;

		[TestInitialize]
		public void InitTest()
		{
			relyingPartyApplicationStoreMock = new Mock<IRelyingPartyApplicationStore>();
			repositoryMock = new Mock<IAppIdentityRepository>();
			tenantRepositoryMock = new Mock<ITenantRepository>();
		}

		[TestMethod]
		[Ignore]
		// This is UT (not integration). It fails because it requires MVC 1.0
		public void HandleNullResponseTest()
		{
			var target = new UserController(
				relyingPartyApplicationStoreMock.Object, 
				repositoryMock.Object,
				tenantRepositoryMock.Object);
			string openid_identifier = "InvalidIdentifier";
			ActionResult result = null; 

			controller.HandleNullResponse(openid_identifier, "", result);

			var actual = result as ViewResult;
			actual.ViewData.ModelState.IsValid.Should().Be.False();
		}
	}
}
